<?php
include_once "MyPDO.php";
include_once "Action.php";
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/11
 * Time: 15:30
 */
class Student extends Action
{
    function login()
    {
        //抓取登录页面上的user和password
        $user=$_POST['user'];
        $password=$_POST['password'];
        //连接数据库
        $db = MyPDO::getInstance();
        $user_sql="select * from t_user where Name='$user'";
        $s_user=$db->select($user_sql);
        //数组转字符串
        //如果有数据
        if(count($s_user)>0)
        {
            if( $s_user[0][2] == $password)
            {
                echo "<meta http-equiv=\"refresh\" content=\"1; url=index.php?action=student&func=lists\">";
                print('登录成功,正在拼命的跳转页面...<br>1秒后自动跳转~~~');
            }
            else
            {
                echo "密码错误!";
            }
        }
        else
        {
            echo "用户名不存在!";
        }
    }

    function lists()
    {
        $db = MyPDO::getInstance();
        $user_sql="select * from t_case";
        $s_user=$db->select($user_sql);
        $this->tp->assign("s_user",$s_user);
        $this->tp->display("list.html");
    }
}